# -*- coding: utf-8 -*-
# @Time    : 2022/5/24 21:10
# @Author  : leijiu
# @Email   : 517711635@qq.com
# @File    : page_add_goods.py
# @Software: PyCharm
"""
添加商品页面
"""
from selenium.webdriver.common.by import By   #引入By类
from selenium.webdriver.support.select import Select  #引入Select类
from page.page_base import BasePage   #引入基类

class AddGoodsPage(BasePage):

    #添加、编辑商品定位器
    #商品名称输入框定位器
    ele_goodsname_locator = (By.NAME, "goods_name")
    #选择商品类型下拉框定位器
    ele_goodstype_locator = (By.CSS_SELECTOR, "#general-table > tbody > tr:nth-child(3) > td:nth-child(2) > select")
    #本店售价输入框定位器
    ele_goodsprice_locator = (By.NAME, "shop_price")
    #添加商品页面确定按钮定位器
    ele_addgoodsbtn_locator = (By.CSS_SELECTOR, "#tabbody-div > form > div > input:nth-child(2)")

        #输入商品名称
    def goods_name(self):
        self.driver.find_element(*self.ele_goodsname_locator).clear()
        self.driver.find_element(*self.ele_goodsname_locator).send_keys("天子")
        # 商品类型选择
    def goods_type(self):
        goodstype_element = self.driver.find_element(*self.ele_goodstype_locator)
        goodstype_select_obj = Select(goodstype_element)
        goodstype_select_obj.select_by_visible_text("    裤子")
        # 先清空，再输入商品售价
    def goods_price(self):
        self.driver.find_element(*self.ele_goodsprice_locator).clear()
        self.driver.find_element(*self.ele_goodsprice_locator).send_keys("112")
        # 点击确定
    def add_goods_btn(self):
        self.driver.find_element(*self.ele_addgoodsbtn_locator).click()